package com.sessioncookie;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * 
 * @classDesc: 功能描述:(创建Session)
 */
@WebServlet("/CreateSessionServlet")
public class CreateSessionServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// 默认是true 标识如果没有session
		// ，就会创建一个sessi,如果false，如果没有摘到session，就不会创建一个session。
		HttpSession session = req.getSession();
		session.setAttribute("userName", "1111");
		System.out.println("保存session成功!"+session.getId());
	}

}
